<?php 
if ($msg != "default") echo $msg_output; 

$query_edit = "SELECT * FROM materials WHERE id='$id'";
$edit = mysql_query($query_edit, $connection) or die(mysql_error());
$row_edit = mysql_fetch_assoc($edit);

if (($action != "confirm") && ($msg == "default")) 
{
?>
<p>Provide a required textbook, journal article, web reading, etc. here.</p>
<?php if ($view != "proposal_detail") { ?><p>Once you are finished, proceed to <a href="index.php?section=proposal_email&amp;action=email&amp;cid=<?php echo $cid; ?>"><?php echo $header_output_next; ?></a>.</p>
<?php } ?>
<div class="stacked">
<span class="icon"><img src="images/disk.png" border="0" align="absmiddle" /></span><input id="submit" name="Submit" type="submit" class="save_progress_form" value="<?php if (($action == "edit") || ($go == "missing")) echo "Update"; else echo "Save"; ?>">
</div>
<table class="dataTable">
<tr style="background-color: <?php echo $color; ?>">
	<td class="dataHeading" width="5%">Material Type:</td>
    <td class="data" width="25%">
    	<input id="matType" name="matType" type="radio" value="1"<?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['matType'] == "1")) echo " CHECKED"; if ($action == "add") echo " CHECKED" ?>> Textbook<br />
        <input id="matType" name="matType" type="radio" value="2"<?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['matType'] == "2")) echo " CHECKED"; ?>> Journal/Periodical<br />
        <input id="matType" name="matType" type="radio" value="3"<?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['matType'] == "3")) echo " CHECKED"; ?>> Web<br />
        <input id="matType" name="matType" type="radio" value="4"<?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['matType'] == "4")) echo " CHECKED"; ?>> 
        Dissertation<br />
        <input id="matType" name="matType" type="radio" value="5"<?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['matType'] == "5")) echo " CHECKED"; ?>> Book Chapter<br />
        <input id="matType" name="matType" type="radio" value="6"<?php if ((($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) && ($row_edit['matType'] == "6")) echo " CHECKED"; ?>> Other
    </td>
    <td class="data"></td>
</tr>
<tr style="background-color: <?php echo $color1; ?>">
	<td class="dataHeading">Title:</td>
    <td class="data"><input id="matTitle" name="matTitle" type="text" size="50" maxlength="255" value="<?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail"))  echo $row_edit['matTitle']; ?>"></td>
    <td class="data help_text">Please use APA style - e.g., Proposals that work: A guide for planning dissertations and grant proposals</td>
</tr>
<tr style="background-color: <?php echo $color; ?>">
	<td class="dataHeading">Author(s):</td>
    <td class="data"><input id="matAuthor" name="matAuthor" type="text" size="50" maxlength="255" value="<?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail"))  echo $row_edit['matAuthor']; ?>"></td>
    <td class="data help_text">Please use APA style - e.g., Author1, X. X., Author2, X. X., &amp; Author3, X. X.</td>
</tr>
<tr style="background-color: <?php echo $color1; ?>">
	<td class="dataHeading">Year Published:</td>
    <td class="data"><input id="matYear" name="matYear" type="text" size="10" maxlength="4" value="<?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail"))  echo $row_edit['matYear']; ?>"></td>
    <td class="data help_text"></td>
</tr>
<tr style="background-color: <?php echo $color; ?>">
	<td class="dataHeading">Publisher/Journal Name:</td>
    <td class="data"><input id="matPublisher" name="matPublisher" type="text" size="30" maxlength="255" value="<?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail"))  echo $row_edit['matPublisher']; ?>"></td>
    <td class="data help_text"></td>
</tr>
<tr style="background-color: <?php echo $color1; ?>">
	<td class="dataHeading">Publisher City, State/Provice:</td>
    <td class="data"><input id="matCity" name="matCity" type="text" size="30" maxlength="255" value="<?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail"))  echo $row_edit['matCity']; ?>"></td>
    <td class="data help_text"></td>
</tr>
<tr style="background-color: <?php echo $color; ?>">
  <td class="dataHeading">e-global Database Name:</td>
  <td class="data"><input id="matEglobal" name="matEglobal" type="text" size="30" maxlength="255" value="<?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail"))  echo $row_edit['matEglobal']; ?>"></td>
  <td class="data help_text">For journals, periodicals, or dissertations only.</td>
</tr>
<tr style="background-color: <?php echo $color1; ?>">
	<td class="dataHeading">ISBN or Accession No.:</td>
    <td class="data"><input id="matISBN" name="matISBN" type="text" size="30" maxlength="255" value="<?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail"))  echo $row_edit['matISBN']; ?>"></td>
    <td class="data help_text">ISBN for textbooks only. Acession number for dissertations.</td>
</tr>
<tr style="background-color: <?php echo $color; ?>">
	<td class="dataHeading">Volume:</td>
    <td class="data"><input id="matVolume" name="matVolume" type="text" size="10" maxlength="255" value="<?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail"))  echo $row_edit['matVolume']; ?>"></td>
    <td class="data help_text">For journals/periodicals.</td>
</tr>
<tr style="background-color: <?php echo $color1; ?>">
	<td class="dataHeading">Issue:</td>
    <td class="data"><input id="matIssue" name="matIssue" type="text" size="10" maxlength="255" value="<?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail"))  echo $row_edit['matIssue']; ?>"></td>
    <td class="data help_text">For journals/periodicals.</td>
</tr>
<tr style="background-color: <?php echo $color; ?>">
	<td class="dataHeading">Pages:</td>
    <td class="data"><input id="matPages" name="matPages" type="text" size="10" maxlength="255" value="<?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) echo $row_edit['matPages']; ?>"></td>
    <td class="data help_text">For journals/periodicals.</td>
</tr>
<tr style="background-color: <?php echo $color1; ?>">
	<td class="dataHeading">Web/e-global URL:</td>
    <td class="data"><input id="matURL" name="matURL" type="text" size="50" maxlength="255" value="<?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail"))  echo $row_edit['matURL']; ?>"></td>
    <td class="data help_text">Website address or e-global permalink URL (<u>including</u> http://).</td>
</tr>
<tr style="background-color: <?php echo $color; ?>">
  <td class="dataHeading">Reason(s) for Choosing:</td>
  <td colspan="2" class="data">
  <textarea id="matInfo" name="matInfo" cols="50" rows="10" class="mceNoEditor"><?php if (($action == "edit") || ($go == "missing") || ($view == "proposal_detail")) echo $row_edit['matInfo']; ?></textarea>
  </td>
  </tr>
</table>
<div class="stacked">
<span class="icon"><img src="images/disk.png" border="0" align="absmiddle" /></span><input id="submit" name="Submit" type="submit" class="save_progress_form" value="<?php if (($action == "edit") || ($go == "missing")) echo "Update"; else echo "Save"; ?>">
</div>
<?php if ($totalRows_materials > 0) { ?>
<h2>Materials Entered Thus Far</h2>
<table class="dataTable">
<?php do { ?>
<tr style="background-color: <?php echo $color; ?>">
	<td class="dataHeading" width="5%">
    <?php if ($row_materials['matType'] == "1") echo "Textbook:"; elseif ($row_materials['matType'] == "2") echo "Journal/Periodical:"; else echo "Web:"; ?>
    </td>
	<?php if ($row_materials['matType'] == "1") { ?>
    <td class="data"><?php echo $row_materials['matAuthor']." (".$row_materials['matYear']."). <em>".$row_materials['matTitle']."</em>. ".$row_materials['matCity'].": ".$row_materials['matPublisher']."."; ?>
    <?php } 
	if ($row_materials['matType'] == "2") { ?>
    <td class="data"><?php echo $row_materials['matAuthor']." (".$row_materials['matYear']."). ".$row_materials['matTitle'].". <em>".$row_materials['matPublisher'].", ".$row_materials['matVolume']."</em>(".$row_materials['matIssue']."), ".$row_materials['matPages']."."; ?>
    <?php } 
	if ($row_materials['matType'] == "3") { ?>
    <td class="data"><?php echo $row_materials['matAuthor']." (".$row_materials['matYear']."). <em>".$row_materials['matTitle']."</em>. Retrieved from: ".$row_materials['matURL']; ?>
    <?php } ?>
</tr>
<?php if ($color == $color1) { $color = $color2; } else { $color = $color1; } ?>
<?php } while ($row_materials = mysql_fetch_assoc($materials)); ?>
</table>
<?php } ?>
<?php }
if ($action == "confirm") 
{ ?>
<h2>Confirm</h2>
<div class="stacked">Is the material description correct?</div>
<div class="stacked"><span class="icon"><img src="images/page_add.png" border="0" align="absmiddle" /></span><a href="index.php?section=proposal_materials&amp;action=add&amp;go=<?php echo $go; ?>&amp;dbTable=materials&amp;cid=<?php echo $cid; ?>&amp;modal_window=<?php echo $modal_window; ?>">Yes, and I wish to add more materials to the list</a></div>
<?php if ($view != "proposal_detail") { ?>
<div class="stacked"><span class="icon"><img src="images/tick.png" border="0" align="absmiddle" /></span><a href="index.php?section=proposal_email&amp;action=email&amp;go=<?php echo $go; ?>&amp;cid=<?php echo $cid; ?>&amp;modal_window=<?php echo $modal_window; ?>">Yes, and I am finished adding materials</a></div>
<?php } ?>
<div class="stacked"><span class="icon"><img src="images/exclamation.png" border="0" align="absmiddle" /></span><a href="index.php?section=proposal_materials&amp;action=edit&amp;go=<?php echo $go; ?>&amp;dbTable=materials&amp;cid=<?php echo $cid; ?>&amp;id=<?php echo $row_edit['id']; ?>&amp;modal_window=<?php echo $modal_window; ?>">No, further edits are required</a></div>
<table class="dataTable">
<tr style="background-color: <?php echo $color1; ?>">
	<td class="dataHeading" width="5%">APA Citation:</td>
	<?php 
	if ($row_edit['matType'] == "1") { ?>
    <td class="data"><?php echo $row_edit['matAuthor']." (".$row_edit['matYear']."). <em>".$row_edit['matTitle']."</em>. ".$row_edit['matCity'].": ".$row_edit['matPublisher']."."; ?>
    <?php } 
	if ($row_edit['matType'] == "2") { ?>
    <td class="data"><?php echo $row_edit['matAuthor']." (".$row_edit['matYear']."). ".$row_edit['matTitle'].". <em>".$row_edit['matPublisher'].", ".$row_edit['matVolume']."</em>(".$row_edit['matIssue']."), ".$row_edit['matPages']."."; ?>
    <?php } 
	if ($row_edit['matType'] == "3") { ?>
    <td class="data"><?php echo $row_edit['matAuthor']." (".$row_edit['matYear']."). <em>".$row_edit['matTitle']."</em>. Retrieved from: ".$row_edit['matURL']; ?>
    <?php } ?>
</tr>
<?php if ($row_edit['matType'] != "3") { ?>
<tr style="background-color: <?php echo $color; ?>">
	<td class="dataHeading" width="5%"><?php if ($row_edit['matType'] == "1") echo "ISBN:"; else echo "e-global Database:"; ?></td>
    <td class="data"><?php echo $row_edit['matISBN']; ?></td>

</tr>
<?php } ?>
<?php if ($row_edit['matType'] != "1") { ?>
<tr style="background-color: <?php echo $color1; ?>">
	<td class="dataHeading" width="5%"><?php if ($row_edit['matType'] == "2") echo "e-global "; ?>URL:</td>
    <td class="data"><?php echo $row_edit['matURL']; ?></td>
</tr>
<?php } ?>
</table>
<?php } ?>